Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kafka fix #1212

Merged
merged 36 commits into from
Aug 2, 2024
Merged

Kafka fix #1212

merged 36 commits into from
Aug 2, 2024

Conversation

ashish-egov
Copy link
Contributor

No description provided.

ashish-egov and others added 30 commits July 25, 2024 12:02
Update V20240731162600__add_uniqiue_constraint_process_track.sql
Copy link
Contributor

coderabbitai bot commented Aug 2, 2024

Walkthrough

Walkthrough

The recent changes involve a significant restructuring of the Kafka messaging components within the application. The function produceModifiedMessages has been relocated from the Listener module to the Producer module, indicating a shift in how messages are produced and managed. This adjustment enhances error handling mechanisms and clarifies the lifecycle of the producer, while also affecting several utility files that utilize this function.

Changes

Files Change Summary
utilities/project-factory/src/server/api/campaignApis.ts, utilities/project-factory/src/server/utils/campaignMappingUtils.ts, utilities/project-factory/src/server/utils/campaignUtils.ts, utilities/project-factory/src/server/utils/genericUtils.ts, utilities/project-factory/src/server/utils/processTrackUtils.ts The import of produceModifiedMessages has been changed from ../kafka/Listener to ../kafka/Producer, indicating a shift in the function's source.
utilities/project-factory/src/server/kafka/Listener.ts The produceModifiedMessages function has been removed, affecting message production functionality.
utilities/project-factory/src/server/kafka/Producer.ts A new createProducer function has been added, improving the producer's lifecycle management. The sendWithRetries function introduces enhanced error handling for message sending. produceModifiedMessages now calls this new function for improved robustness.

Sequence Diagram(s)

sequenceDiagram
    participant Utils as Utility Functions
    participant Producer as Kafka Producer
    participant Listener as Kafka Listener

    Utils->>Producer: call produceModifiedMessages()
    Producer->>Producer: createProducer()
    Producer->>Producer: sendWithRetries()
    Producer->>Utils: log success/error
Loading

🐰 Hop, hop, hooray!
The messages find their way!
From Listener to Producer’s call,
We simplify our code for all.
With retries and logs anew,
Let’s cheer for changes bright and true! 🥕


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 84cda56 and 7f84d1a.

Files selected for processing (7)
  • utilities/project-factory/src/server/api/campaignApis.ts (1 hunks)
  • utilities/project-factory/src/server/kafka/Listener.ts (2 hunks)
  • utilities/project-factory/src/server/kafka/Producer.ts (2 hunks)
  • utilities/project-factory/src/server/utils/campaignMappingUtils.ts (1 hunks)
  • utilities/project-factory/src/server/utils/campaignUtils.ts (1 hunks)
  • utilities/project-factory/src/server/utils/genericUtils.ts (1 hunks)
  • utilities/project-factory/src/server/utils/processTrackUtils.ts (1 hunks)
Additional comments not posted (11)
utilities/project-factory/src/server/kafka/Listener.ts (1)

4-4: LGTM! But verify the impact of the removed import statement.

The removal of the throwError import statement is approved.

However, ensure that there are no references to throwError in this file.

Verification successful

No issues found with the removed import statement.

The throwError import statement was removed, and there are no references to throwError in utilities/project-factory/src/server/kafka/Listener.ts.

  • The removal does not impact the file.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that there are no references to `throwError` in this file.

# Test: Search for references to `throwError`. Expect: No occurrences.
rg --type ts 'throwError' utilities/project-factory/src/server/kafka/Listener.ts

Length of output: 80

utilities/project-factory/src/server/kafka/Producer.ts (4)

21-33: LGTM! Ensure proper initialization of the producer.

The createProducer function is correctly implemented and the event listeners are properly set up.


60-89: LGTM! Ensure proper handling of retries and errors.

The sendWithRetries function is correctly implemented and the retry logic is properly handled.


92-108: LGTM! But verify the impact of the relocated function.

The produceModifiedMessages function is correctly integrated and the call to sendWithRetries is properly handled.

However, ensure that all references to produceModifiedMessages are updated to the new location.

Verification successful

All references to produceModifiedMessages are correctly updated to the new location.

The function produceModifiedMessages is correctly integrated, and all references point to the new location in Producer.ts.

  • utilities/project-factory/src/server/utils/campaignUtils.ts
  • utilities/project-factory/src/server/utils/genericUtils.ts
  • utilities/project-factory/src/server/utils/processTrackUtils.ts
  • utilities/project-factory/src/server/utils/campaignMappingUtils.ts
  • utilities/project-factory/src/server/api/campaignApis.ts
  • utilities/project-factory/src/server/kafka/Producer.ts
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that all references to `produceModifiedMessages` are updated to the new location.

# Test: Search for references to `produceModifiedMessages`. Expect: Only occurrences of the new location.
rg --type ts 'produceModifiedMessages'

Length of output: 3568


110-110: LGTM! But verify the impact of the updated export statement.

The export statement is correctly updated to export produceModifiedMessages instead of producer.

However, ensure that there are no references to the producer export in the codebase.

Verification successful

The export statement update is correctly implemented.

  • No references to producer were found, confirming it is safe to remove its export.
  • Multiple references to produceModifiedMessages confirm it is correctly used in the codebase.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that there are no references to the `producer` export in the codebase.

# Test: Search for references to the `producer` export. Expect: No occurrences.
rg --type ts 'producer' --glob '!Producer.ts'

Length of output: 45


Script:

#!/bin/bash
# Description: Verify that there are no references to the `producer` export and that `produceModifiedMessages` is correctly referenced in the codebase.

# Test 1: Search for references to the `producer` export. Expect: No occurrences.
rg --type ts '\bproducer\b' --glob '!Producer.ts'

# Test 2: Search for references to `produceModifiedMessages` to ensure it is being used correctly.
rg --type ts 'produceModifiedMessages'

Length of output: 3620

utilities/project-factory/src/server/utils/processTrackUtils.ts (1)

2-2: LGTM! But verify the impact of the updated import statement.

The import statement is correctly updated to reference produceModifiedMessages from Producer.ts instead of Listener.ts.

However, ensure that the new reference does not introduce any issues.

Verification successful

LGTM! But verify the impact of the updated import statement.

The import statement is correctly updated to reference produceModifiedMessages from Producer.ts instead of Listener.ts.

  • The function produceModifiedMessages is correctly defined in Producer.ts.
  • The function is correctly exported from Producer.ts.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the new reference to `produceModifiedMessages` does not introduce any issues.

# Test: Search for references to `produceModifiedMessages` in this file. Expect: No issues with the new reference.
rg --type ts 'produceModifiedMessages' utilities/project-factory/src/server/utils/processTrackUtils.ts

Length of output: 388


Script:

#!/bin/bash
# Description: Verify that `produceModifiedMessages` is correctly defined and exported in `Producer.ts`.

# Locate the definition of `produceModifiedMessages` in `Producer.ts`
ast-grep --lang typescript --pattern 'function produceModifiedMessages($_, $_) { $$$ }'

# Locate the export statement for `produceModifiedMessages` in `Producer.ts`
rg 'export { produceModifiedMessages }' --type ts

Length of output: 1960


Script:

#!/bin/bash
# Description: Verify that `produceModifiedMessages` is correctly exported in `Producer.ts`.

# Locate the export statement for `produceModifiedMessages` in `Producer.ts`
rg 'export .*produceModifiedMessages' --type ts

Length of output: 140

utilities/project-factory/src/server/utils/campaignMappingUtils.ts (1)

6-6: Ensure the new import path is correct.

The import statement for produceModifiedMessages has been updated. Verify that the new path ../kafka/Producer is correct and that the produceModifiedMessages function is exported from this module.

Verification successful

The import path is correct.

  • The produceModifiedMessages function is defined in utilities/project-factory/src/server/kafka/Producer.ts.
  • It is correctly exported from this module.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the export of `produceModifiedMessages` from `../kafka/Producer`.

# Test: Search for the export of `produceModifiedMessages` in the Producer module. Expect: The function should be exported.
rg --type ts -A 5 $'export function produceModifiedMessages'

Length of output: 61


Script:

#!/bin/bash
# Description: Locate the definition of `produceModifiedMessages` in the entire codebase.

# Test: Search for the definition of `produceModifiedMessages`. Expect: The function should be defined somewhere in the codebase.
rg --type ts 'function produceModifiedMessages'

Length of output: 182


Script:

#!/bin/bash
# Description: Verify the export of `produceModifiedMessages` from `Producer.ts`.

# Test: Search for the export statement of `produceModifiedMessages` in `Producer.ts`. Expect: The function should be exported.
rg --type ts 'export.*produceModifiedMessages' utilities/project-factory/src/server/kafka/Producer.ts

Length of output: 139

utilities/project-factory/src/server/api/campaignApis.ts (1)

11-11: Ensure the new import path is correct.

The import statement for produceModifiedMessages has been updated. Verify that the new path ../kafka/Producer is correct and that the produceModifiedMessages function is exported from this module.

Verification successful

The import path is correct.

The produceModifiedMessages function is correctly exported from utilities/project-factory/src/server/kafka/Producer.ts, and the import path used in campaignApis.ts is accurate.

  • utilities/project-factory/src/server/kafka/Producer.ts: The function is defined and exported here.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the export of `produceModifiedMessages` from `../kafka/Producer`.

# Test: Search for the export of `produceModifiedMessages` in the Producer module. Expect: The function should be exported.
rg --type ts -A 5 $'export function produceModifiedMessages'

Length of output: 61


Script:

#!/bin/bash
# Description: Verify the existence of `Producer` module and the export of `produceModifiedMessages` function.

# Locate the Producer module
echo "Searching for Producer module..."
fd 'Producer.ts'

# Verify the export of produceModifiedMessages function
echo "Verifying the export of produceModifiedMessages function..."
rg 'produceModifiedMessages' -A 5

Length of output: 17833

utilities/project-factory/src/server/utils/genericUtils.ts (1)

5-5: Ensure the new import path is correct.

The import statement for produceModifiedMessages has been updated. Verify that the new path ../kafka/Producer is correct and that the produceModifiedMessages function is exported from this module.

Verification successful

The import path is correct.

The produceModifiedMessages function is correctly exported from the utilities/project-factory/src/server/kafka/Producer.ts module.

  • utilities/project-factory/src/server/kafka/Producer.ts: export { produceModifiedMessages };
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the export of `produceModifiedMessages` from `../kafka/Producer`.

# Test: Search for the export of `produceModifiedMessages` in the Producer module. Expect: The function should be exported.
rg --type ts -A 5 $'export function produceModifiedMessages'

Length of output: 61


Script:

#!/bin/bash
# Description: Verify the export of `produceModifiedMessages` from the `Producer` module.

# Search for named exports of `produceModifiedMessages`
rg --type ts -A 5 'export function produceModifiedMessages'

# Search for named exports in an export block
rg --type ts -A 5 'export { produceModifiedMessages }'

# Search for default exports that might include the function
rg --type ts -A 5 'export default { produceModifiedMessages }'

Length of output: 451


Script:

#!/bin/bash
# Description: Verify the export of `produceModifiedMessages` from the `Producer` module.

# Search for named exports of `produceModifiedMessages`
rg --type ts -A 5 'export function produceModifiedMessages'

# Search for named exports in an export block
rg --type ts -A 5 'export \{ produceModifiedMessages \}'

# Search for default exports that might include the function
rg --type ts -A 5 'export default \{ produceModifiedMessages \}'

# Search for any export statements that might include produceModifiedMessages
rg --type ts -A 5 'export .*produceModifiedMessages'

Length of output: 424

utilities/project-factory/src/server/utils/campaignUtils.ts (2)

5-5: Verify the correctness of the import change.

The import statement for produceModifiedMessages has been updated from ../kafka/Listener to ../kafka/Producer. Ensure that the new module provides the same functionality and that all references to produceModifiedMessages are correct.

Verification successful

Verified: The import statement for produceModifiedMessages is correct and consistent.

The produceModifiedMessages function is defined in utilities/project-factory/src/server/kafka/Producer.ts and is correctly exported. The import statement in utilities/project-factory/src/server/utils/campaignUtils.ts is accurate.

  • utilities/project-factory/src/server/kafka/Producer.ts: Function definition and export.
  • utilities/project-factory/src/server/utils/campaignUtils.ts: Correct import and usage.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the `produceModifiedMessages` function is correctly imported from the new module.

# Test: Search for the function definition in the new module.
rg --type ts -A 5 $'export function produceModifiedMessages' ../kafka/Producer

Length of output: 137


Script:

#!/bin/bash
# Description: Search for the `produceModifiedMessages` function definition across the entire codebase.

# Test: Search for the function definition in the entire codebase.
rg --type ts -A 5 $'export function produceModifiedMessages'

Length of output: 61


Script:

#!/bin/bash
# Description: Search for the `produceModifiedMessages` function name across the entire codebase.

# Test: Search for the function name in the entire codebase.
rg 'produceModifiedMessages'

Length of output: 3558


Line range hint 818-821: Verify the usage of produceModifiedMessages.

Ensure that the usage of produceModifiedMessages in the generateProcessedFileAndPersist function is correct and consistent with its definition in the new module.

Verification successful

The usage of produceModifiedMessages in the generateProcessedFileAndPersist function is correct and consistent with its definition in the new module.

  • The function produceModifiedMessages is defined to take two parameters: modifiedMessages and topic.
  • In campaignUtils.ts, it is consistently called with two arguments, which align with its definition.
Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the usage of `produceModifiedMessages` in the `generateProcessedFileAndPersist` function.

# Test: Search for the function usage. Expect: Consistent usage with the new module definition.
rg --type ts -A 5 $'produceModifiedMessages' utilities/project-factory/src/server/utils/campaignUtils.ts

Length of output: 3117


Script:

#!/bin/bash
# Description: Locate and review the definition of `produceModifiedMessages` in the `../kafka/Producer` module.

# Search for the definition of `produceModifiedMessages` in the `../kafka/Producer` module.
ast-grep --lang typescript --pattern 'function produceModifiedMessages($_, $_) { $$$ }' 

Length of output: 1782

@jagankumar-egov jagankumar-egov merged commit ae1e89e into campaign Aug 2, 2024
3 of 4 checks passed
@jagankumar-egov jagankumar-egov deleted the kafkaFix branch August 2, 2024 05:30
Bhavya-egov pushed a commit that referenced this pull request Aug 12, 2024
* Update Listener.ts

* added new branch

* Update Listener.ts

* fixed mapping kafka error

* mapping kafka fixed

* fix kafka

* fix kafka

* Removing foreign key constraint

* Producer update

* Revert "Ashish egov patch 2 (#1178)"

This reverts commit e86a4dc.

* Update Producer.ts

* Update Producer.ts

* Feat : updated producemodified message

* Feat : removed waiting

* adding constraint

* Update V20240731162600__add_uniqiue_constraint_process_track.sql

* Update constants.ts

* Feat : improved kafka

* Fix kafka restart issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants